package com.claims

class Dependant extends Person {

  Long id
  String relation
  Employee parent
  Boolean study

  static belongsTo = [Employee]
  static transients = ["age"];

  /**
   * constraints
   */
  static constraints = {
    relation(inList: ['SELF', 'CHILD', 'WIFE', 'HUSBAND'])
  }

  def getAge(){
    return (int) ((System.currentTimeMillis() - dateOfBirth.getTime())/(24*60*60*1000));  
  }


  /**
   * to string
   */
  public String toString() {
    return "${name}"
  }
  static mapping = {
    sort name:'asc'
  }
}
